package com.example.day23;

import java.util.ArrayList;

/**
 * @author Lenovo
 */
public class StreamDemo {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        list.add("林青霞");
        list.add("张曼玉");
        list.add("王祖贤");
        list.add("柳岩");
        list.add("张敏");
        list.add("张无忌");
        ArrayList<String> zhangList = new ArrayList<String>();

        for(String s : list) {
            if(s.startsWith("张")) {
                zhangList.add(s);
    }
}
        ArrayList<String> threeList = new ArrayList<String>();

        for(String s : zhangList) {
            if (s.length() == 3) {
                threeList.add(s);
            }
        }
        for(String s : threeList) {
            System.out.println(s);
        }
        System.out.println("------------------------" );
        list.stream().filter(s -> s.startsWith("张")).filter(s -> s.length() ==
                3).forEach(System.out::println);

    }
}
